import { createApp } from "vue";
import App from "./App.vue";
import "./assets/app.css"; //import css file

import { createRouter, createWebHistory } from "vue-router";
import OrderManage from "./func/OrderManage.vue";
import DailyAlert from "./func/DailyAlert.vue";
import OrderNew from "./func/OrderNew.vue";
import CompanyManage from "./func/CompanyManage.vue";
import CompanyDetail from "./func/CompanyDetail.vue";
import MaterialManage from "./func/MaterialManage.vue";
import Material from "./func/Material.vue";
import MaterialDetail from "./func/MaterialDetail.vue";
import Calendar from "./func/Calendar.vue";
import ContactManage from "./func/ContactManage.vue";
import ContactDetail from "./func/ContactDetail.vue";

const routes = [
  { path: "/order", component: OrderManage },
  { path: "/alert", component: DailyAlert },
  { path: "/ordernew/:id?", component: OrderNew },
  { path: "/company", component: CompanyManage },
  {
    path: "/materials/:id?",
    name: "materials",
    component: MaterialManage,
  },
  {
    path: "/material/:id?",
    name: "material",
    component: Material,
  },
  {
    path: "/materialdetail/:id?",
    name: "materialdetail",
    component: MaterialDetail,
  },
  {
    path: "/company/detail/:id?",
    name: "companydetail",
    component: CompanyDetail,
  },
  {
    path: "/calendar",
    name: "calendar",
    component: Calendar,
  },
  // ✅ 修正：为 ContactManage 页面使用不同的 name
  {
    path: "/contacts",
    name: "contactmanage", // 修改为 contactmanage
    component: ContactManage,
  },
  // ✅ 修正：ContactDetail 页面保留 contactdetail
  {
    path: "/contact/:id?",
    name: "contactdetail", // 保持唯一
    component: ContactDetail,
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

createApp(App).use(router).mount("#app");
